﻿
using System.Collections.Generic;
using HuaCheng.DataAccess;
namespace HuaCheng.Controller
{
    public class AuthorityControl
    {
        /// <summary>
        /// 获得当前用户的权限
        /// </summary>
        /// <param name="groupType"></param>
        /// <returns></returns>
        public static List<string> GetAuthority(string userName)
        {
            //用于存储当前用户的权限
            List<string> codeList = new List<string>();
            //获取当前登录用户所属用户组名称
            if (userName != null)
            {
                string groupType = UserInfoHelper.RetrieveUserinfo(userName).Groupname;
                //获取该用户组的权限code
                string strMenuCode = UserGroupHelper.RetrieveMenuCode(groupType);
                string[] arrCode;
                if (!string.IsNullOrEmpty(strMenuCode))
                {
                    arrCode = strMenuCode.Split(new char[] { ',' });
                    for (int i = 0; i < arrCode.Length; i++)
                    {
                        codeList.Add(arrCode[i]);
                    }
                }
            }
            return codeList;
        }
    }
}
